﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using UtilZ.Dotnet.Ex.Model;

namespace ConAppCore.Test
{
    internal class TestTransferData
    {
        public static void Test()
        {
            //TestMemoryStreamOffset();
            TestGetBufferDataFilePath();

            var xx2 = Array.MaxLength;


            Test222();
        }


        private static void Test222()
        {
            using (var ms = new MemoryStream())
            {
                var bw = new BinaryWriter(ms);
                bw.Write('a');
                var buffer = ms.GetBuffer();
                var buffer2 = ms.ToArray();
            }
        }

        private static void TestGetBufferDataFilePath()
        {
            var filePath = TransferDataOptions.Default.GenerateBufferDataFilePath();
            TransferDataOptions.Default.BufferDataFileDirectory = @"D:\tmp";
            var filePath2 = TransferDataOptions.Default.GenerateBufferDataFilePath();
        }

        private static void TestMemoryStreamOffset()
        {
            byte[] buffer = Encoding.UTF8.GetBytes("abcdefg");
            using (var ms = new MemoryStream(buffer, 2, buffer.Length - 2))
            {
                var reader = new BinaryReader(ms);
                char ch = reader.ReadChar();
                if (ch == 'c')
                {

                }

            }
        }

    }
}

